package org.duang.config;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.duang.kit.ToolsKit;

/**
 * 配置参数
 * @author laotang
 *
 */
public class Config {
	
	public static final String DUANG_LINK_REQUEST_THREAD_ID = "duang_link_request_thread_id";
	
	private static String BASE_PACKAGE_PATH = "";
	
	private static String ENCODING = ""; 
	
	private static int MAX_POST_SIZE = 0;
	
	private static String DEFAULT_DATE_FORM = "";
	
	private static String MONGODB_HOST = "";
	
	private static String MONGODB_PORT = "";
	
	private static String MONGODB_DB_NAME = "";
	
	private static String MONGODB_DB_USERNAME = "";
	
	private static String MONGODB_DB_PWD = "";
	
	private static String MONGODB_DB_REPLICASET = "";
	
	private static String VIEW_ROOT_PATH = "";
	
	public final static String CONTROLLER_ENDWITH_NAME = "Controller.class";
	
	public final static String SERVICE_ENDWITH_NAME = "Service.class";
	
	public final static String DAO_ENDWITH_NAME = "Dao.class";
	
	public final static String LISTENER_ENDWITH_NAME = "Monitor.class";
	
	private static Boolean DEBUG = null;
	
	private static String UPLOADFILE_ROOT_DIRECTORY = "";
	
	private static Set<String> UPLOADFILE_EXTNAME_SET = null;
	
	private static String UPLOADFILE_SITE = "";
	
	private static String MVC_CONFIG_PACKAGE_PATH = "";
	
	private static long PUSH_TIMEOUT = -1;
	
	private static boolean IS_SECURITY = false;
	
	private static String IS_ENABLE_DRL = "";
	
	private static String IS_ANYC_EVENT = "false";
	
	private static String PRODUCT_CODE = "";
	
	private static String FILE_HOST_SITE = "";
	
	private static String THUMBNAIL_HOST_SITE = "";
	
	private static String THUMBNAIL_HOST_SITE_EXT = "";
	
	private static String TOKEN_NAME = "";
	
	private static long MIN_SECONDS_OF_TOKEN_TIME_OUT = 0l;
	
	private static String PUSH_URL = "";								// 推送路径
	
	private static String SECURITY_LOGIN_URL = "";						// 登录Action路径
	
	private static String SECURITY_LOGIN_IN_URL = "";					// 提交登录URL	
	
	private static String SECURITY_LOGIN_OUT_URL = "";				// 退出登录URL
	
	private static String SECURITY_UNAUTHORIZED_URL = "";			// 验证出错URL
	
	private static String SECURITY_STATIC_FIELD = "";				// 静态文件过滤URL
	
	private static String[] SECURITY_FILTER_URLS = null;			// 安全验证URL
	
	private static String[] SECURITY_NOT_FILTER_URLS = null;			// 安全验证URL
	
	private static String MYSQL_HOST = "";
	
	private static String MYSQL_PORT = "";
	
	private static String ZK_SYNCLOCK_HOST = "";
	
	private static String SQL_DATA_SOURCE = "";
	
	private static String SQL_DB_USERNAME="";
	
	private static String SQL_DB_PASSWORD = "";
	
	private static String SQL_DB_URL = "";
	
	private static String SIGN_KEY = "";
	
	private static String ES_CLUSTER_NAME = "";
	
	private static String ES_INDEX_NAME = "";
	
	private static String ES_TYPENAME = "";
	
	private static String ES_REPLICASET = "";
	
	private static int ES_PORT = 0;
	
	private static String WEB_SOCKET_HOST = "";
	
	private static String WEB_SOCKET_PORT = "";
	
	private static String LOGBACK_LEVEL = "";
	
	private static String PAY_HOST = "";
	
	private static String PROPERTIES_URL_PATH = "http://file.sythealth.com/config/5LiJ55uK5aCC/duang/properties/";
	
	private static Configuration configuration = null;
	public static final Configuration getConfiguration() {		
		try {
			if(null == configuration){				
				configuration = new PropertiesConfiguration("duang.properties");
				if(ToolsKit.isNotEmpty(configuration) && ToolsKit.isAliyunHost()) {   //如果是布署到正式生产环境下的，则通过URL读取对应的配置文件
					String ip = ToolsKit.getLocalHostIP();
					PRODUCT_CODE = configuration.getString("product.code");					
					if(ToolsKit.isEmpty(PRODUCT_CODE)) throw new NullPointerException("duang.properties[product.code] is null !!!");
					configuration.clear();
					String urlString  = PROPERTIES_URL_PATH;
					if(ip.equals("42.96.139.238") || ip.equals("10.129.20.220")) {
						urlString += "slb/";
					}
					configuration =getConfigurationByUrl(urlString, PRODUCT_CODE+".properties");
				}
			}
			return configuration;
		} catch (Exception e) {
			try{
				configuration = new PropertiesConfiguration("duangbase.properties");
				return configuration;
			} catch(Exception ex){
				throw new NullPointerException("Cannot find duang.properties !!!");
			}
		}
	}
	
	/**
	 * 根据配置文件并返回Configuration对象
	 * @param propertiesName
	 * @return
	 * @throws Exception
	 */
	public static Configuration getConfiguration(String propertiesName) throws Exception { 
		if(ToolsKit.isEmpty(propertiesName)) throw new NullPointerException("get properties fail:  "  + propertiesName + " is null");
		return new PropertiesConfiguration(propertiesName);
	}
	
	/**
	 * 根据配置文件名取网络上的配置文件并返回Configuration对象
	 * @param propertiesName
	 * @return
	 * @throws Exception
	 */
	public static Configuration getConfigurationByUrl(String urlStr, String propertiesName) throws Exception {
		String urlString = urlStr + propertiesName;
		URL url = new URL(urlString);
		if(ToolsKit.isEmpty(url)) throw new NullPointerException("get properties fail:  "  + urlString);
		return new PropertiesConfiguration(url);
	}
	
	/**
	 * 取根包路径
	 * @return
	 */
	public static String getBasePackagePath(){
		if(ToolsKit.isEmpty(BASE_PACKAGE_PATH)){
			BASE_PACKAGE_PATH = Config.getConfiguration().getString("base.package.path", "com");
		} 
		return BASE_PACKAGE_PATH;
	}
	
	/**
	 * 取最大文件上传容量
	 * @return
	 */
	public static int getMaxPostSize(){
		if( MAX_POST_SIZE == 0){
			MAX_POST_SIZE = Config.getConfiguration().getInt("max.post.size", 10485760);
		}
		return MAX_POST_SIZE;
	}
	
	/**
	 * 字符编码
	 * @return
	 */
	public static String getEncoding() {
		if(ToolsKit.isEmpty(ENCODING)){
			ENCODING = Config.getConfiguration().getString("encoding", "UTF-8");
		}
		return ENCODING;
	}
	
	/**
	 * 取默认日期时间格式(yyyy-MM-dd HH:mm:ss)
	 * @return
	 */
	public static String getDefaultDateFormat(){
		if(ToolsKit.isEmpty(DEFAULT_DATE_FORM)){			
			DEFAULT_DATE_FORM = Config.getConfiguration().getString("default.date.format", "yyyy-MM-dd HH:mm:ss");
		}
		return DEFAULT_DATE_FORM;
	}
	
	/**
	 * URL字符串参数分隔符
	 * @return
	 */
	public static String getSeparated() {
		return java.io.File.separator;
	}
	
	public static String getMongoDBHost() {
		if(ToolsKit.isEmpty(MONGODB_HOST)){			
			MONGODB_HOST = Config.getConfiguration().getString("mongodb.host", "127.0.0.1");
		}
		return MONGODB_HOST;
	}
	
	public static String getMongoDBPort() {
		if(ToolsKit.isEmpty(MONGODB_PORT)){			
			MONGODB_PORT = Config.getConfiguration().getString("mongodb.port", "27017");
		}
		return MONGODB_PORT;
	}
	
	public static String getMongoDBName() {
		if(ToolsKit.isEmpty(MONGODB_DB_NAME)){			
			MONGODB_DB_NAME = Config.getConfiguration().getString("mongodb.databasename", "local");
		}
		return MONGODB_DB_NAME;
	}
	
	public static String getMongoDBUserName() {
		if(ToolsKit.isEmpty(MONGODB_DB_USERNAME)){			
			MONGODB_DB_USERNAME = Config.getConfiguration().getString("mongodb.username", "");
		}
		return MONGODB_DB_USERNAME;
	}
	
	public static String getMongoDBPassword() {
		if(ToolsKit.isEmpty(MONGODB_DB_PWD)){			
			MONGODB_DB_PWD = Config.getConfiguration().getString("mongodb.password", "");
		}
		return MONGODB_DB_PWD;
	}
	
	public static String getMongoDBReplicaset() {
		if(ToolsKit.isEmpty(MONGODB_DB_REPLICASET)){
			String[] list = getPropertieArray("mongodb.replicaset");
			if(ToolsKit.isEmpty(list)) return "";
			StringBuffer sb = new StringBuffer();
			for(String str : list){
				sb.append(str).append(",");	
			}
			if(sb.length() > 0)
				MONGODB_DB_REPLICASET = sb.deleteCharAt(sb.length()-1).toString();
		}
		return MONGODB_DB_REPLICASET;
	}
	
	
	public static String getViewRootPath(){		
		if(ToolsKit.isEmpty(VIEW_ROOT_PATH)){
			String path = Config.getConfiguration().getString("view.path", "pages");
			VIEW_ROOT_PATH = "/WEB-INF/"+ path;
		}
		return VIEW_ROOT_PATH;
	}
	
	public static boolean getDebug(){		
		if(ToolsKit.isEmpty(DEBUG)){
			DEBUG = Config.getConfiguration().getBoolean("debug", false);
		}
		return DEBUG.booleanValue();
	}
	
	public static String getProductCode() {
		if(ToolsKit.isEmpty(PRODUCT_CODE)){
			PRODUCT_CODE = Config.getConfiguration().getString("product.code", "duangduangduang");
		}
		return PRODUCT_CODE;
	}
	
	/**
	 * 上传文件根目录
	 * @return
	 */
	public static String getUploadFileServerRootDirectory(){
		if(ToolsKit.isEmpty(UPLOADFILE_ROOT_DIRECTORY)){
			UPLOADFILE_ROOT_DIRECTORY = Config.getConfiguration().getString("uploadfile.directory", "updatefiles"); 
		}
		return UPLOADFILE_ROOT_DIRECTORY.startsWith("/") ? UPLOADFILE_ROOT_DIRECTORY : "/"+UPLOADFILE_ROOT_DIRECTORY; 
		
	}
	
	/**
	 * 允许上传的文件扩展名集合
	 * @return
	 */
	public static Set<String> getUploadFileExtNames(){
		if(ToolsKit.isEmpty(UPLOADFILE_EXTNAME_SET)){
			UPLOADFILE_EXTNAME_SET = new HashSet<String>();
			String[] tmp = {"jpg","png","bmp","gif","rar","zip","7z","docx","doc","xlsx","xls","txt","apk"};
			String[] tmps = Config.getPropertieArray("uploadfile.extname");
			if(ToolsKit.isEmpty(tmps) || tmps.length == 0)  tmps = tmp; 
			for(String str : tmps){
				UPLOADFILE_EXTNAME_SET.add(str.toLowerCase());
			}
		}
		return UPLOADFILE_EXTNAME_SET;
	}
	
	public static String getUploadFileSite() {
		if(ToolsKit.isEmpty(UPLOADFILE_SITE)){
			UPLOADFILE_SITE = Config.getConfiguration().getString("uploadfile.site", "local");
		}
		return UPLOADFILE_SITE;
	}
	
	
	public static void setPushTimeout(long timeout) {
		if(PUSH_TIMEOUT == -1){
			PUSH_TIMEOUT = timeout;
		}
	}
	
	public static long getPushTimeout() {
		return PUSH_TIMEOUT;
	}
	
	public static void setEnadleSecurity(boolean security){
		IS_SECURITY = true;
	}
	
	public static boolean getEnadleSecurity(){
		return IS_SECURITY;
	}
	
	public static String getMvcConfigPackagePath() {
		if(ToolsKit.isEmpty(MVC_CONFIG_PACKAGE_PATH)){
			MVC_CONFIG_PACKAGE_PATH = Config.getConfiguration().getString("mvc.config", "");
		}
		return MVC_CONFIG_PACKAGE_PATH;
	}
	
	public static String getFileHostSite() {
		if(ToolsKit.isEmpty(FILE_HOST_SITE)){
			FILE_HOST_SITE = Config.getConfiguration().getString("file.host", "http://file.sythealth.com");
		}
		return FILE_HOST_SITE;
	}
	
	public static String getThumbnailHostSite() {
		if(ToolsKit.isEmpty(THUMBNAIL_HOST_SITE)){
			THUMBNAIL_HOST_SITE = Config.getConfiguration().getString("thumbnail.host", "http://thumbnail.sythealth.com");
		}
		return THUMBNAIL_HOST_SITE;
	}
	
	public static String getThumbnailHostSiteExt() {
		if(ToolsKit.isEmpty(THUMBNAIL_HOST_SITE_EXT)){
			THUMBNAIL_HOST_SITE_EXT = Config.getConfiguration().getString("thumbnail.hostext", "@1e_140w_140h_0c_0i_1o_90Q_1x.jpg");
		}
		return THUMBNAIL_HOST_SITE_EXT;
	}
	
	
	
	public static String getTokenName(){
		if(ToolsKit.isEmpty(TOKEN_NAME)){
			TOKEN_NAME = Config.getConfiguration().getString("token.name", "mvc_token");
		}
		return TOKEN_NAME;
	}
	
	public static long getTokenTimeOut(){
		if(MIN_SECONDS_OF_TOKEN_TIME_OUT == 0l){
			MIN_SECONDS_OF_TOKEN_TIME_OUT = Config.getConfiguration().getLong("token.time", 600);		//10分钟过期
		}
		return MIN_SECONDS_OF_TOKEN_TIME_OUT;
	}

	public static String getSecurityLoginUrl() {
		if(ToolsKit.isEmpty(SECURITY_LOGIN_URL)){
			SECURITY_LOGIN_URL = Config.getConfiguration().getString("login.url", "/login");
		}
		return SECURITY_LOGIN_URL;
	}


	public static String getSecurityLoginInUrl() {
		if(ToolsKit.isEmpty(SECURITY_LOGIN_IN_URL)){
			SECURITY_LOGIN_IN_URL = Config.getConfiguration().getString("loginin.url", "/login/in");
		}
		return SECURITY_LOGIN_IN_URL;
	}

	public static String getSecurityLoginOutUrl() {
		if(ToolsKit.isEmpty(SECURITY_LOGIN_OUT_URL)){
			SECURITY_LOGIN_OUT_URL = Config.getConfiguration().getString("loginout.url", "/login/out");
		}
		return SECURITY_LOGIN_OUT_URL;
	}


	public static String getSecurityUnauthorizedUrl() {
		if(ToolsKit.isEmpty(SECURITY_UNAUTHORIZED_URL)){
			SECURITY_UNAUTHORIZED_URL = Config.getConfiguration().getString("unauthorized.url", "/unauthorized");
		}
		return SECURITY_UNAUTHORIZED_URL;
	}
	


	public static String getSecurityStaticField() {
		if(ToolsKit.isEmpty(SECURITY_STATIC_FIELD)){
			SECURITY_STATIC_FIELD = Config.getConfiguration().getString("static.field", "/static") + "/**";
		}
		return SECURITY_STATIC_FIELD;
	}
	
	public static String getPushUrl() {
		if(ToolsKit.isEmpty(PUSH_URL)){
			PUSH_URL = Config.getConfiguration().getString("mvc.push", "/push") + "/**";
		}
		return PUSH_URL;
	}
	
	public static String[] getSecurityFilterUrls() {
		if(ToolsKit.isEmpty(SECURITY_FILTER_URLS )){
			SECURITY_FILTER_URLS = Config.getConfiguration().getStringArray("mvc.security.urls");
			if(ToolsKit.isEmpty(SECURITY_FILTER_URLS)){
				SECURITY_FILTER_URLS = new String[1]; 
				SECURITY_FILTER_URLS[0] = "/main/**";
			}
		}
		return SECURITY_FILTER_URLS;
	}
	
	public static String[] getNotSecurityFilterUrls() {
		if(ToolsKit.isEmpty(SECURITY_NOT_FILTER_URLS )){
			SECURITY_NOT_FILTER_URLS = Config.getConfiguration().getStringArray("mvc.not.security.urls");
			if(ToolsKit.isEmpty(SECURITY_NOT_FILTER_URLS)){
				SECURITY_NOT_FILTER_URLS = new String[1]; 
				SECURITY_NOT_FILTER_URLS[0] = "/notsecurity/**";
			}
		}
		return SECURITY_NOT_FILTER_URLS;
	}
	
	public static String getMysqlHost(){
		if(ToolsKit.isEmpty(MYSQL_HOST)){
			MYSQL_HOST = Config.getConfiguration().getString("mysql.host", "");
		}
		return MYSQL_HOST;
	}
	public static String getMysqlPort(){
		if(ToolsKit.isEmpty(MYSQL_PORT)){
			MYSQL_PORT = Config.getConfiguration().getString("mysql.port", "");
		}
		return MYSQL_PORT;
	}
	
	
	public static String getZKSyncLockHost(){
		if(ToolsKit.isEmpty(ZK_SYNCLOCK_HOST)){
			ZK_SYNCLOCK_HOST = Config.getConfiguration().getString("zookeeper.host", "");
		}
		return ZK_SYNCLOCK_HOST;
	}
	
	public static String getSqlDataSource(){
		if(ToolsKit.isEmpty(SQL_DATA_SOURCE)){
			SQL_DATA_SOURCE = Config.getConfiguration().getString("sql.datasource", "");
		}
		return SQL_DATA_SOURCE;
	}
	
	public static String getSqlUrl() {
		if(ToolsKit.isEmpty(SQL_DB_URL)){			
			SQL_DB_URL= Config.getConfiguration().getString("sql.url", "");
		}
		return SQL_DB_URL;
	}
	
	public static String getSqlDBUserName() {
		if(ToolsKit.isEmpty(SQL_DB_USERNAME)){			
			SQL_DB_USERNAME = Config.getConfiguration().getString("sql.username", "");
		}
		return SQL_DB_USERNAME;
	}
	
	public static String getSqlDBPassword() {
		if(ToolsKit.isEmpty(SQL_DB_PASSWORD)){			
			SQL_DB_PASSWORD = Config.getConfiguration().getString("sql.password", "");
		}
		return SQL_DB_PASSWORD;
	}
	
	public static String getSignKey() {
		if(ToolsKit.isEmpty(SIGN_KEY)){			
			SIGN_KEY = Config.getConfiguration().getString("signkey", "duangduangduang");
		}
		return SIGN_KEY;
	}
	
	public static String getElasticSearchClusterName() {
		if(ToolsKit.isEmpty(ES_CLUSTER_NAME)){			
			ES_CLUSTER_NAME = Config.getConfiguration().getString("es.clustername", "elasticsearch");
		}
		return ES_CLUSTER_NAME;
	}
	
	public static String getElasticSearchIndexName() {
		if(ToolsKit.isEmpty(ES_INDEX_NAME)){			
			ES_INDEX_NAME = Config.getConfiguration().getString("es.indexname", getMongoDBName());
		}
		return ES_INDEX_NAME;
	}
	
	public static String getElasticSearchTypeName() {
		if(ToolsKit.isEmpty(ES_TYPENAME)){			
			ES_TYPENAME = Config.getConfiguration().getString("es.typename", "sys_logback");
		}
		return ES_TYPENAME;
	}
	
	public static String getElasticSearchReplicaset() {
		if(ToolsKit.isEmpty(ES_REPLICASET)){			
			String[] list = getPropertieArray("es.replicaset");
			if(ToolsKit.isEmpty(list)) return "";
			StringBuffer sb = new StringBuffer();
			for(String str : list){
				sb.append(str).append(",");	
			}
			if(sb.length() > 0)
				ES_REPLICASET = sb.deleteCharAt(sb.length()-1).toString();
		}
		return ES_REPLICASET;
	}
	
	public static int getElasticSearchPort() {
		if(0 ==ES_PORT){			
			ES_PORT = Config.getConfiguration().getInt("es.port", 9300);
		}
		return ES_PORT;
	}
	
	public static String getWebSocketHost() {
		if(ToolsKit.isEmpty(WEB_SOCKET_HOST)){			
			WEB_SOCKET_HOST = Config.getConfiguration().getString("socket.host", "0.0.0.0");
		}
		return WEB_SOCKET_HOST;
	}
	
	public static String getWebSocketPort() {
		if(ToolsKit.isEmpty(WEB_SOCKET_PORT)){			
			WEB_SOCKET_PORT = Config.getConfiguration().getString("socket.port", "8731");
		}
		return WEB_SOCKET_PORT;
	}
	
	public static String getPayHost() {
		if(ToolsKit.isEmpty(PAY_HOST)){	
			PAY_HOST = Config.getConfiguration().getString("pay.host", "http://pay.sythealth.com");
			if(PAY_HOST.endsWith("/")) PAY_HOST = PAY_HOST.substring(0, PAY_HOST.length()-1);
		}
		return PAY_HOST;
	}

	

//	############################### SMS #################################
	
	public static String SMS_TYPE;
	public static String SIGN_NAME;
	public static String ACCESS_KEY;
	public static String ACCESS_KEY_SECRET;
	public static String SMS_URL;
	public static String SMS_TEMPLLATE_REPLACEKEY;
	public static int MAX_RCENUM = 0;

	public static String getSmsType() {
		if (null == SMS_TYPE)
			SMS_TYPE = getPropertie("sms_type", "normal"); 
		return SMS_TYPE;
	}

	public static String getSignName() {
		if (null == SIGN_NAME)
			SIGN_NAME = getPropertie("sign_name", "轻加"); 
		return SIGN_NAME;
	}

	public static String getAccessKey() {
		if (null == ACCESS_KEY)
			ACCESS_KEY = getPropertie("accesskey","23274057");
		return ACCESS_KEY;
	}

	public static String getAccessKeySecret() {
		if (null == ACCESS_KEY_SECRET)
			ACCESS_KEY_SECRET =  getPropertie("accesskey_secret","c8b976c64baaa4b01dfb213b8aac01d3");
		return ACCESS_KEY_SECRET;
	}

	public static String getSmsUrl() {
		if (null == SMS_URL)
			SMS_URL = getPropertie("sms_url", "http://gw.api.taobao.com/router/rest");
		return SMS_URL;
	}
	
	public static int getMaxRecNum() {
		if (0 == MAX_RCENUM) {
			MAX_RCENUM =  getPropertie("max_recnum", 200);
		}
		return MAX_RCENUM;
	}

	public static String getSmsTemplateUrl() {
		return getPropertie("sms_template_url", "http://file.sythealth.com/config/5LiJ55uK5aCC/fitness/sms_template.json");
	}

	public static String getCharEncode() {
		return getPropertie("char_encode", "UTF-8");
	}

	public static String getSmsTemplateReplaceKey() {
		if (null == SMS_TEMPLLATE_REPLACEKEY) {
			SMS_TEMPLLATE_REPLACEKEY = getPropertie("sms_template_replacekey", "${_#_}");
		}
		return SMS_TEMPLLATE_REPLACEKEY;
	}
	
	public static String getSmsClientExample() {
		return getPropertie("sms_client_example", "org.duang.sms.client.TaobaoSmsClient");
	}
	
	
	public static String getLogBackLevel() {
		if (ToolsKit.isEmpty(LOGBACK_LEVEL)) {
			LOGBACK_LEVEL = getPropertie("logback_level", "warn");
		}
		return LOGBACK_LEVEL.toUpperCase();
	}
	
	public static String getLogBackFactoryExample() {
		return getPropertie("logback_factory_example", "org.duang.logs.LogBackFactory");
	}
	
	public static int getSessionTimeOut() {
		return getPropertie("session.time.out", 1800);
	}
	
	public static boolean isEnableDRL() {
		if (ToolsKit.isEmpty(IS_ENABLE_DRL)) {
			IS_ENABLE_DRL = getPropertie("enable.drl", "false");
		}
		return Boolean.parseBoolean(IS_ENABLE_DRL);
	}
	
	public static boolean isAsyncEvent() {
//		if (ToolsKit.isEmpty(IS_ANYC_EVENT)) {
//			IS_ANYC_EVENT = getPropertie("event.anyc", "true");
//		}
		return Boolean.parseBoolean(IS_ANYC_EVENT);
	}
	
	
	public static String getEmailUser() {
		return getPropertie("eamil.username", "");
	}
	public static String getEmailPwd() {
		return getPropertie("email.password", "");
	}
	
	public static String getEmailSmtp() {
		return getPropertie("smtp.host", "smtp.exmail.qq.com");
	}
	public static int getEmailSmtpProt() {
		return getPropertie("smtp.prot", 465);
	}

	//#########################################################
	
	public static final String getPropertie(final String key, final String defaultValue){
		return Config.getConfiguration().getString(key, defaultValue).trim();
	}
	public static final int getPropertie(final String key, final int defaultValue){
		return Config.getConfiguration().getInt(key, defaultValue);
	}
	
	public static final boolean getPropertie(final String key, final boolean defaultValue){
		return Config.getConfiguration().getBoolean(key, defaultValue);
	}
	
	public static final String[] getPropertieArray(final String key){
		return Config.getConfiguration().getStringArray(key);
	}
	
	public static final Iterator<String> getKeys(){
		return Config.getConfiguration().getKeys();
	}
}

